<?php
/**
 * Modelo de la tabla SC_SetupSeguimiento 
 * @author natanael
 * 
 */

class MSetupSeguimiento extends Model
{
	
	private $_nameTable = "SC_SetupSeguimiento";
	
	public function __construct()
	{
	    parent::Model();

	}
	
    public function loadObjeto($start = false, $offset = false, $sortname = false, $sortorder = false)
    {
          if($offset != false)
		       $this->db->limit($offset, $start);

		   if($sortname != false && $sortorder != false) 
			    $this->db->order_by($sortname, $sortorder);
				  
		    $result = $this->db->get_where($this->_nameTable);
	
			return $this->GetArrayFromQueryResult($result);
			
     }
     
    public function LoadObjetoById($id) 
	{
		  $qresult = $this->db->get_where($this->_nameTable, array('Id' => $id));		
		
		  if ($qresult->num_rows() == 0)
		  {
			return false;
		  }	
           
		  return new ScSetupSeguimiento($qresult->row());
	}
	
    public function LoadObjetoByArray($where) 
	{
		  $qresult = $this->db->get_where($this->_nameTable, $where);		
		
		  if ($qresult->num_rows() == 0)
		  {
			return false;
		  }	
           
		  return new ScSetupSeguimiento($qresult->row());
	}
     
    public function GetArrayFromQueryResult($result) 
	{
			if ($result->num_rows() == 0)
				return false;
	
			$query_arr = array();
	
			foreach ($result->result() as $record) {
				$query_arr[] = new ScSetupSeguimiento($record);
		    }
	
			return $query_arr;
     }
     
     public function addReguistro($data)
     {
          if($this->db->insert($this->_nameTable,$data)){
           	  return true;
          }
           
           return false;
      }
      
      public function editReguistro($data, $id)
      {
           if ($this->db->update($this->_nameTable,$data,array('Id'=>$id))) {
           	  return true;
           }
           
            return false;
       }
       
      public function deleteReguistro($id)
      {
           if ($this->db->delete($this->_nameTable,array('Id'=>$id))) {
           	  return true;
           }
           
            return false;
       }
}

class ScSetupSeguimiento
{
	private $_id;
    private $_idEtapa;
    private $_idScript;
    private $_tipo;
    
    public function __construct($ojt)
    {
    	$this->setId($ojt->Id);
        $this->setIdEtapa($ojt->IdEtapa);
        $this->setIdScript($ojt->IdScript);
        $this->setTipo($ojt->Tipo);
    }
    
    public function setId($value)
    {
       $this->_id = $value;
    }
    
    public function getId()
    {
       return $this->_id;
    }
    
    public function setIdEtapa($value)
    {
       $this->_idEtapa = $value;
    }
    
    public function getIdEtapa()
    {
       return $this->_idEtapa;
    }
    
    public function setIdScript($value)
    {
       $this->_idScript = $value;
    }
    
    public function getIdScript()
    {
       return $this->_idScript;
    }
    
    public function setTipo($value)
    {
       $this->_tipo = $value;
    }
    
    public function getTipo()
    {
       return $this->_tipo;
    }
 
} 